<?php

use think\swoole\websocket\socketio\Handler;

return [
    /*'server'     => [
        'enable'     => true,
        'host'      => env('SWOOLE_HOST', '0.0.0.0'), // 监听地址
        'port'      => env('SWOOLE_PORT', 8090), // 监听端口
        'mode'      => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS
        'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP
        'options'   => [ // 都是给 Swoole 服务的配置，可以根据 Swoole 手册额外增加其它的 Swoole 配置
            'pid_file'              => runtime_path() . 'swoole.pid', //服务启动以后进程 ID 存放文件
            'log_file'              => runtime_path() . 'swoole.log', //Swoole 的日志文件
            'daemonize'             => false, //守护进程模式设置，true 后台运行
            // Normally this value should be 1~4 times larger according to your cpu cores.
            'reactor_num'           => swoole_cpu_num(), //后台启动的 Reactor 线程数
            'worker_num'            => swoole_cpu_num(), //设置启动的 Worker 进程数
            'task_worker_num'       => swoole_cpu_num(), //配置 Task 进程数
            'enable_static_handler' => true, //开启静态文件请求处理功能，需配合 document_root
            'document_root'         => root_path('public'), //配置静态文件根目录
            'package_max_length'    => 20 * 1024 * 1024, //设置最大数据包尺寸，单位为字节
            'buffer_output_size'    => 10 * 1024 * 1024, //配置发送输出缓存区内存尺寸
            'socket_buffer_size'    => 128 * 1024 * 1024, //用于设置客户端连接最大允许占用内存数量
        ],
    ],*/
    /*'http'       => [
        'enable'     => true,
        'host'       => '0.0.0.0',
        'port'       => 9503,
        'worker_num' => swoole_cpu_num(),
        'options'    => [],
        'coroutine' => [
            'enable' => true,
            'flags' => SWOOLE_HOOK_ALL,
        ],
    ],*/
    /*'http' => [
        'server' => [
            'setup' => [
                'root'      => __DIR__,
                'host'      => '0.0.0.0',
                'port'      => 8090,
                'mode'      => SWOOLE_PROCESS,
                'worker_num'=> 4, // 设置工作进程数
                // 其他 Swoole 配置...
            ],
        ],
    ],*/
    /*'websocket'  => [
        'enable'        => true,
        'handler'       => Handler::class,
        'httpRequest'=>\app\http\OnRequestEvent::class,
        'ping_interval' => 25000,
        'ping_timeout'  => 60000,
        'room'          => [
            'type'  => 'table',
            'table' => [
                'room_rows'   => 8192,
                'room_size'   => 2048,
                'client_rows' => 4096,
                'client_size' => 2048,
            ],
            'redis' => [
                'host'          => '127.0.0.1',
                'port'          => 6379,
                'max_active'    => 3,
                'max_wait_time' => 5,
            ],
        ],
        'listen'        => [
            'swoole.websocket.Event'=>\app\http\OnRequestEvent::class,
            'swoole.request'=>\app\http\OnRequestEvent::class
            ],
        'subscribe'     => [],
    ],
    'rpc'        => [
        'server' => [
            'enable'     => false,
            'host'       => '0.0.0.0',
            'port'       => 9000,
            'worker_num' => swoole_cpu_num(),
            'services'   => [],
        ],
        'client' => [],
    ],
    'queue'      => [
        'enable'  => false,
        'workers' => [],
    ],*/
    'http'       => [
        'enable'     => true,
        'host'       => '0.0.0.0',
        'port'       => 8090,
        'worker_num' => 20,
        'task_worker_num'=>20,
        'package_max_length' => 40 * 1024 * 1024, // 最大请求包长度 20M
        'request_slowlog_timeout' => 10, // 请求超时时间 2 秒
        'set' => [ // Swoole服务器配置
            'worker_num' => 60, // 根据CPU核心数设置工作进程数量，这里设置为核心数的两倍作为示例
            // 其他Swoole配置...
        ],
        'options'    => [
            'worker_num' => 80
        ],
    ],
    /*'coroutine' => [
        'enable' => true,
        'flags' => SWOOLE_HOOK_ALL,
    ],*/
    'hot_update' => [
        'enable'  => env('APP_DEBUG', false),
        'name'    => ['*.php'],
        'include' => [app_path()],
        'exclude' => [],
    ],
    'pool'       => [
        'db'    => [
            'enable'        => true,
            'max_active'    => 3,
            'max_wait_time' => 5,
        ],
        'cache' => [
            'enable'        => true,
            'max_active'    => 3,
            'max_wait_time' => 5,
        ],
    ],
    'task_worker_num'=>20,
    'tables'     => [],
    'concretes'  => [],
    'resetters'  => [],
    'instances'  => [],
    'services'   => [],
];
